package com.jd.charactercalculator.controller.common;


import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author: 袁征
 * @since: 12-7-31 上午11:12
 * @version: 1.0.0
 */
public class BaseController extends MultiActionController {

    /**
     * 获取用户名
     * @return 用户名
     */
    protected String getUsername(){
        return "admin";
    }

    /**
     * 获取Ip
     * @param request request
     * @return IP
     */
    protected String getRemoteIP(HttpServletRequest request){
        String ip = request.getRemoteAddr();
        if (request.getHeader("x-forwarded-for") != null
                && !"unknown".equalsIgnoreCase(request.getHeader("x-forwarded-for"))) {
            ip = ip + "," + request.getHeader("x-forwarded-for");
        }
        return ip;
    }

}
